<template>
  <div style="width: 100%; height: 100%; position: relative">
    <div
      style="
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        top: 30px;
        z-index:1000000;
      "
    >
      <el-select v-model="form.className" filterable placeholder="请选择班级"
        ><el-option
          v-for="item in classList"
          :key="item.className"
          :label="item.className"
          :value="item.className"
        ></el-option>
      </el-select>
    </div>
    <div id="main" style="width: 100%; height: 100%"></div>
  </div>
</template>
<script>
import * as echarts from "echarts/core";
import {
  TitleComponent,
  TooltipComponent,
  LegendComponent,
} from "echarts/components";
import { PieChart } from "echarts/charts";
import { LabelLayout } from "echarts/features";
import { CanvasRenderer } from "echarts/renderers";
echarts.use([
  TitleComponent,
  TooltipComponent,
  LegendComponent,
  PieChart,
  CanvasRenderer,
  LabelLayout,
]);
export default {
  name: "Home",
  data() {
    return {
      form: {
        student_Number: "",
        password: "",
        SecondaryCollege: "",
        className: "",
        studentName: "",
        grade: "",
      },
      classList: [],
      chart: null,
      option: {
        title: {
          text: "班级综测提交情况",
          //   subtext: "Fake Data",
          left: "center",
        },
        tooltip: {
          trigger: "item",
        },
        legend: {
          orient: "vertical",
          left: "left",
        },
        series: [
          {
            name: "综测数据",
            type: "pie",
            radius: "50%",
            data: [
              { value: 1048, name: "审核通过" },
              { value: 735, name: "审核不通过" },
              { value: 580, name: "已提交" },
              { value: 484, name: "未提交" },
              { value: 300, name: "未审核" },
            ],
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: "rgba(0, 0, 0, 0.5)",
              },
            },
          },
        ],
      },
    };
  },
  created() {
     
    this.getClass();
  },
  mounted() {
    var chartDom = document.getElementById("main");
    var myChart = echarts.init(chartDom);
    this.option && myChart.setOption(this.option, "dark");
  },
  methods: {
    getClass() {
      const userInfo = JSON.parse(localStorage.getItem("userInfo"));
      this.form.className=userInfo.className
      this.$request.get("/getClassList/getClass", {}).then(({ data }) => {
        this.classList= data.data.filter((item)=>{
            return item.SecondaryCollege===userInfo.SecondaryCollege
        })[0].classList;
        console.log(this.classList);

      });
    },
  },
};
</script>
<style lang="scss" scoped>
</style>